#ifndef LONGKEY_BASE_SHELL_H_
#define LONGKEY_BASE_SHELL_H_

#include <Windows.h>
#include <shlobj.h>   // for the CSIDL definitions
#include <atlstr.h>
#include <map>
#include "basictypes.h"


enum UseBrowser
{
	USE_DEFAULT_BROWSER = 0,
	USE_INTERNET_EXPLORER = 1,
	USE_FIREFOX = 2
};


class Shell
{
public:

	// create and store a shortcut link
	// note that icon can be NULL if no icon is required
	// note that we always pick the 0th icon for now, this can be changed later
	// [relevant with EXE and compound icons]
	static HRESULT CreateLink(const TCHAR *source,
		const TCHAR *destination,
		const TCHAR *working_dir,
		const TCHAR *arguments,
		const TCHAR *description,
		WORD hotkey_virtual_key_code,
		WORD hotkey_modifiers,
		const TCHAR *icon);
	// For information on hotkey modifiers see MSDN IShellLink::GetHotKey method.

	// Delete a shortcut link
	static HRESULT RemoveLink(const TCHAR *link);

	// Open a URL in a new browser window
	static HRESULT OpenLinkInNewWindow(const TCHAR* url, UseBrowser use_browser);

	// Execute a file
	static HRESULT Shell::Execute(const TCHAR* file);

	// Get the location of a special folder.  The special folders are identified
	// by a unique integer - see the platform SDK files shfolder.h and
	// shlobj.h.  (These names will be the localized versions for the
	// system that is running.)
	static HRESULT GetSpecialFolder(DWORD csidl,
		bool create_if_missing,
		CString* folder_path);

	// Get a mapping from special folder "env var" names to special folder
	// pathnames.
	// Provides mappings for: APPDATA, DESKTOP, LOCALAPPDATA, MYMUSIC, MYPICTURES,
	// PROGRAMFILES, PROGRAMFILESCOMMON, PROGRAMS, STARTMENU, STARTUP, SYSTEM,
	// WINDOWS.
	static HRESULT GetSpecialFolderKeywordsMapping(
		std::map<CString, CString>* special_folders_map);

	// Recursively delete a directory including its files.
	static HRESULT DeleteDirectory(const TCHAR* dir);

	// Reads the application executable path from
	// HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths.
	static HRESULT GetApplicationExecutablePath(const CString& exe,
		CString* path);

private:

	static HRESULT BasicGetSpecialFolder(DWORD csidl, CString* folder_path);

	DISALLOW_EVIL_CONSTRUCTORS(Shell);
};

#endif	// LONGKEY_BASE_SHELL_H_